package com.aizuda.boot.modules.business.approval.controller;

import com.aizuda.boot.modules.business.approval.entity.dto.NegotiationListQueryDTO;
import com.aizuda.boot.modules.business.approval.entity.vo.ContractListVO;
import com.aizuda.boot.modules.business.approval.entity.vo.NegotiationListVO;
import com.aizuda.boot.modules.business.approval.service.ApprovalControlService;
import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.contract.entity.dto.ContractWorkflowListQueryDTO;
import com.aizuda.boot.modules.common.constant.enums.ResponseCodeEnum;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author sangyirong
 * @ClassName ApprovalControlController
 * @Version 1.0
 * @Date 2025/7/14 17:24
 */
@RestController
@RequestMapping("/approvalControl")
@Tag(name = "审批控制")
@Slf4j
public class ApprovalControlController {


    @Resource
    private ApprovalControlService approvalControlService;


    @Operation(summary = "获取干预合同流程列表")
    @PostMapping("list")
    public SingleResponse<IPage<ContractListVO>> list(@RequestBody ContractWorkflowListQueryDTO dto) {
        try {
            return approvalControlService.list(dto);
        } catch (Exception e) {
            log.error("获取合同流程列表失败", e);
            return SingleResponse.failure(ResponseCodeEnum.SYS_ERROR.getCode(), ResponseCodeEnum.SYS_ERROR.getMsg());
        }

    }

    @Operation(summary = "获取审核流程干预列表")
    @PostMapping("negotiation")
    public SingleResponse<IPage<NegotiationListVO>> negotiationList(@RequestBody NegotiationListQueryDTO dto){
        try {
            return approvalControlService.negotiationList(dto);
        } catch (Exception e) {
            log.error("获取审核流程干预列表失败", e);
            return SingleResponse.failure(ResponseCodeEnum.SYS_ERROR.getCode(), ResponseCodeEnum.SYS_ERROR.getMsg());
        }
    }
}
